
import sys
from tkinter import *


def window(list):
    if len(list) == 0:
        return
    window = Tk()
    window.title('故障设备')
    window.geometry('300x330')
    li = list
    listb = Listbox(window)  # 创建两个列表组件
    # listb.exportselection = 1
    for item in li:                 # 第一个小部件插入数据
        listb.insert(0, item) # 0 逆序 1 顺序 插入
    listb.pack(fill=BOTH, expand=True)                    # 将小部件放置到主窗口中
    window.mainloop()


def main(sys):
    list = ['51 1-1', '52 1-2']
    window(list)


if __name__ == "__main__":
    main(sys)
